import { defineStore } from "pinia";
import { ref } from "vue";

export const useLoginStore = defineStore('login', () => {
    const token = ref('')

    const setToken = ((t) => {
        token.value = t;
    })

    return {
        token,
        setToken
    }
}, {
    persist: {
        key: 'login-store', // 存储的key
        storage: localStorage, // 默认localStorage
        paths: ['token'], // 只持久化name和token
        beforeRestore: (ctx) => {
            console.log('加载token')
        },
        afterRestore: (ctx) => {
            console.log('token加载完成')
        }
    }
})